A file is a named collection of related information that appears to the user as a single contiguous block of data retained in storage media. Data blocks are structures used to store the actual data for the file. A file system is a structuring of data and metadata on storage media, which permits reading/writing of data on those media. In one embodiment, the file system is a hierarchy of directories, i.e. a directory tree, that is used to organize files on a computer. An inode is a data structure on a file system used to store information about a file, such as metadata. The information contained in an inode may include ownership of the file, access permission for the file, size of the file, file type and references to locations on disk of the data blocks for the file. Inodes are often stored in a contiguous table on disk media, and the inode number of a file is an integer that is the index of its inode in this table. When a file is created, it is assigned both a name and an inode number. The file has an inode number by virtue of being rooted in an inode, and it has a name by virtue of having an entry created for it in some directory. The data in a directory is minimally a list of pairs of file names along with their corresponding inode numbers, noting that directories will themselves have entries in a parent directory—that is, most directories are subdirectories of some other directory. Only the root directory of a file system has no explicit parent directory in the file system. Whenever a user or a program refers to a file by name, the system uses that name to search directories in the file system. The search begins with the root and successively reads and searches subdirectories, until the file's complete name has been used and the search finds the inode for the file, which enables the system to obtain the information it needs about the file, i.e. metadata, to perform further operations.
File systems may be exported across a network from a source location to a target location by passing out an encapsulated reference to an inode table index to file system clients. As used herein, the term “source” can be broadly defined as a location from which the subject data of this invention travels, and the term “target” can be defined as the location to which the data travels. FIG. 1 is a block diagram (10) of a storage system environment that includes a pair of interconnected file servers, including a source file server (20) and a target file server (40). The source and target file servers (20) and (40), respectively, are linked via a network (30) that can comprise a local or wide area network. An appropriate network adapter (32), (52) residing in communication with each file server (20) and (40) in communication with the network (30) through a network connections (22), (42), respectively, facilitates communication over the network (30). The source and target file servers (20) and (40) each respectively include a processor (26), (46), memory (28), (48), and a network adapter (32), (52). Each file server (20), (40) also includes a storage operating system (not shown) that implements a file system to logically organize information as a hierarchical structure of directories and files on storage media.
There are several known methods for replicating file systems across a network. One prior art method for replicating a file system duplicates the source file system's directory tree. An application at the source file system traverses the directory tree presented and copies each file and directory to the destination file system. FIG. 2 is a prior art block diagram (100) showing a sample inode table of a source file system. As shown, there are three entries in addition to the root directory (102), each of the entries are at indexes four (104), six (106), and seven (108) in the inode table. In this example, index one (102) is the root directory, index four (104) has an entry for an executable image for an edit program, index six (106) is a subdirectory, and index seven (108) has a readable text file. As shown, there are no entries at indexes two (110), three (112), and five (114). The reason for the empty indices may vary. For example, an index may be empty because the files that once resided in the index may have been deleted.
FIG. 3 is a block diagram (150) showing a sample inode table at a target file system as interpreted from the sample source inode table in FIG. 2 using the prior art inode table replication process described above. As shown, the order of the node table indices from the source file system are not preserved during the duplication process, and the empty indices have not been preserved. The order of the node table indexes are not specific and may be presented in alphabetical order, numerical order, etc. Accordingly, even though a given file at the target file system may be a copy of the same file at the source file system, their network file references are not interchangeable.
Another prior art method for replicating a file system copies the file system by duplicating each file and directory in the inode table in numerical order. For example, the file corresponding to the first node is copied from the source file system to the target file system. This is followed by the file corresponding to the second node, and each of the files corresponding to each successive node in the source file system's node table. However, one drawback associated with this method is that the intermediate state of the target file system will be inconsistent with itself because files are copied in an arbitrary order relative to their being referenced by a parent directory. For example, an inconsistent state is created when a directory entry that serves as a reference to a file is copied to the target file system before the file itself is copied, leaving a directory entry for a file not yet present. Conversely, another inconsistent state might be created when a file is copied from the source file system to the target file system before the directory entry for that file is copied from the source file system to the target file system. This intermediate state produces files that exist and consume space, but which are not pointed to by any directory entry, i.e., having no name. Both of these intermediate states are moot when the copy is completed without interruption, since files in the source and target file systems will have the same inode numbers, all files will have directory entries, and all directory entries will correspond to files, as in the source file system. However, there is a significant drawback associated with the two identified intermediate states and this occurs when there is an interruption in the replication process after a first entry is made in the target file system. An interruption in the prior art replication processes results in a partial target file system that is self-inconsistent and is not salvageable.
Therefore, there is a need for a method for replicating a file system that preserves the order of the inode table entries at all stages of the replication process, including all intermediate stages. The solution should ensure that if an interruption should occur during the replication process, the target file system remnants are salvageable.